package net.xxcxcxcx.xc_enhancedmob.skills.basics.individual.mystery;

import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.packet.s2c.play.EntityPositionS2CPacket;
import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.xxcxcxcx.xc_enhancedmob.config.skill.SkillConfig;
import net.xxcxcxcx.xc_enhancedmob.skills.BaseSkill;
import net.xxcxcxcx.xc_enhancedmob.skills.Ref;
import net.xxcxcxcx.xc_enhancedmob.skills.SkillRarity;

public class FallSkill extends BaseSkill {

    public FallSkill(int level){super(level);}

    public FallSkill(NbtCompound nbtCompound){super(nbtCompound);}

    public FallSkill(){
    }

    @Override
    public SkillConfig getDefaultConfig() {
        SkillConfig skillConfig = super.getDefaultConfig();
        skillConfig.setMessage(getConfigMessage(skillConfig));
        return skillConfig;
    }

    @Override
    public String getConfigMessage(SkillConfig skillConfig) {
        return "每隔一段时间立刻提高目标的高度";
    }

    public SkillRarity getSkillRarity(){return SkillRarity.Mystery;}

    @Override
    public boolean canUseAbility(MobEntity mobEntity) {
        return mobEntity.world.getTime()>getSkilltime();
    }

    @Override
    public boolean onAbilityUse(MobEntity mobEntity) {
        if(canUseAbility(mobEntity))
        {
            LivingEntity target = mobEntity.getTarget();
            if(target != null && !mobEntity.world.isClient)
            {
                double X = target.getX();
                double Y = target.getY()+getSkillLevel()*2.0d;
                double Z = target.getZ();
                target.teleport(X,Y,Z,true);
                if(target.hasVehicle())
                {
                    target.stopRiding();
                }
                setSkilltime(mobEntity.world.getTime()+getCooldown());
            }
        }
        return true;
    }
}
